package com.tarena.lbs.content.controller;

import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.content.pojo.param.ArticleCategoryParam;
import com.tarena.lbs.content.pojo.vo.ArticleCategoryVO;
import com.tarena.lbs.content.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 处理文章分类 业务模块功能
 */
@Api(tags = "文章分类管理")
@RestController
public class CategoryController {
    @Resource
    private CategoryService categoryService;

    @ApiOperation("文章分类列表查询")
    @GetMapping("/admin/content/category/list")
    public Result<PageResult<ArticleCategoryVO>> pageList(){
        PageResult<ArticleCategoryVO> pageResult = categoryService.pageList();
        return new Result<>(pageResult);
    }
    // 插入分类
    @PostMapping("/admin/content/category/insert")
    public Result<Void> insert(ArticleCategoryParam articleCategoryParam){
        categoryService.insert(articleCategoryParam);
        return Result.success();
    }
}
